using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ImmediateWindow
{
	public partial class BlankCompilationUnitForm : Form, IInputOutputForm
	{
		List<string> itsAvailRefs;
		List<string> itsRefs;
		List<string> itsOutputLines;
		CompilerKnobs itsKnobs;

		public BlankCompilationUnitForm(string[] prelines)
		{
			InitializeComponent();
			itsOutputLines = new List<string>();
			if(prelines!=null && prelines.Length>0)
				CodeTextBox.Lines = prelines;
		}
		private void ConsoleForm_Layout(object sender, LayoutEventArgs e)
		{
			Utility.AdjustSize(this);
		}

		string TemplateCode="{0}";

		#region IInputOutputForm Members

		public string[] GetSourceLines()
		{
			StringBuilder codelines = new StringBuilder();
			foreach (string line in CodeTextBox.Lines)
				codelines.Append(line + Environment.NewLine);
			return new string[] { string.Format(TemplateCode, codelines.ToString()) };
		}

		public object[] GetArguments()
		{
			return new object[] { ArgTextBox.Text.Trim().Split(' ') };
		}

		public void WriteOutput(string text)
		{
			itsOutputLines.Add(text);
			OutputTextBox.Lines = itsOutputLines.ToArray();
		}
		public void ClearOutput()
		{
			itsOutputLines.Clear();
			OutputTextBox.Clear();
		}

		public List<string> References { get { return itsRefs; } set{itsRefs=value;}}
		public List<string> AvailableReferences { get { return itsAvailRefs; } set { itsAvailRefs = value; } }
		public CompilerKnobs CompilerOption { get { return itsKnobs; } set { itsKnobs = value; } }
		public Control[] GetFontControls()
		{
			return new Control[] { CodeTextBox, OutputTextBox, HeadLabel};
		}

		#endregion
	}
}